﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TJDevHouse.Starcraft.Game
{
	public class BuildTile : Tile
	{
		public BuildTile(Map map, int x, int y) : base(map, x, y) { }

		public BuildTile(Map map, int x, int y, bool buildable)
			: base(map, x, y)
		{
			_buildable = buildable;
		}

		private bool _buildable;

		public override bool GetIsWalkable()
		{
			foreach (WalkTile wt in GetWalkTiles())
			{
				if (!wt.IsWalkable)
				{
					return false;
				}
			}

			return true;
		}

		public override bool GetHeight()
		{
			throw new InvalidOperationException("Height data only available on walk tiles");
		}

		public override bool GetIsBuildable()
		{
			return _buildable;
		}

		public override BuildTile GetBuildTile()
		{
			return this;
		}

		public override List<WalkTile> GetWalkTiles()
		{
			return Map.GetWalkTilesAtBuildTileCoords(X, Y);
		}

		public override void SetIsWalkable(bool walkable)
		{
			throw new InvalidOperationException("Can not set walkability at build tile level");
		}

		public override void SetHeight(bool height)
		{
			throw new InvalidOperationException("Can not set height at build tile level");
		}

		public override void SetIsBuildable(bool buildable)
		{
			_buildable = buildable;
		}
	}
}
